/********************************************************************************
	Test Functions - Group 1
********************/
#define g01fn01			1
#define g01fn02			2
#define g01fn03			3

#define g01Sphere		1
#define g01Rosenbrock	2
#define g01Rastrigin	3

#if test_function == 1
	#ifndef dimension
		#define dimension			5
	#endif
	#ifndef lower_bound
		#define lower_bound			-100.0
	#endif
	#ifndef upper_bound
		#define upper_bound			100.0
	#endif
	#define func_name			"Sphere"
	#define func				fn_sphere
	double func_min=0.0;
	double* min_vector;
	void build_min_vector(){
		int i;
		min_vector=(double*)malloc(sizeof(double)*dimension);
		for(i=0;i<dimension;i++)
			min_vector[i]=0.0;
	}
	double fn_sphere(double* x){
		int i;
		double r=0;
		for(i=0;i<dimension;i++){
			r+=x[i]*x[i];
		}
		return r;
	}
#endif

#if test_function == 2
	#define dimension			2
	#ifndef lower_bound
		#define lower_bound			-2.048
	#endif
	#ifndef upper_bound
		#define upper_bound			2.048
	#endif
	#define func_name			"Rosenbrock"
	#define func				fn_rosenbrock2D
	double func_min=0.0;
	double* min_vector;
	void build_min_vector(){
		int i;
		min_vector=(double*)malloc(sizeof(double)*dimension);
		for(i=0;i<dimension;i++)
			min_vector[i]=1.0;
	}
	double fn_rosenbrock2D(double* x){
		double r;
		double t1,t2;
		t1=x[1]-x[0]*x[0];
		t2=x[0]-1;
		r=100*t1*t1+t2*t2;
		return r;
	}
#endif

#if test_function == 3
	#ifndef dimension
		#define dimension			10
	#endif
	#ifndef lower_bound
		#define lower_bound			-600.0
	#endif
	#ifndef upper_bound
		#define upper_bound			600.0
	#endif
	#define func				fn_rastrigin
	#define func_name			"Rastrigin"
	double func_min=0.0;
	double* min_vector;
	void build_min_vector(){
		int i;
		min_vector=(double*)malloc(sizeof(double)*dimension);
		for(i=0;i<dimension;i++)
			min_vector[i]=0.0;
	}
	double fn_rastrigin(double* x){
		int i;
		double r=0;
		for (i=0;i<dimension;i++){
			r+=(x[i]*x[i]-10*cos(2*3.141529*x[i])+10);
		}
		return r;
	}
#endif
